package org.dftproject.genesis.ui.pages.place;

import jp.sf.mapswidgets.GoogleMaps;

import org.dftproject.genesis.ui.pages.AbstractPagePart;
import org.dftproject.genesis.ui.pages.IPageInput;
import org.dftproject.genesis.ui.pages.IPageSite;
import org.dftproject.genesis.ui.pages.PageInitException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

public class PlacePage extends AbstractPagePart {

	public static final String ID = PlacePage.class.getName();

	private GoogleMaps map;
	
	public void init(IPageSite site, IPageInput input) throws PageInitException {
		if (!(input instanceof PlacePageInput))
			throw new PageInitException("input must be a " + PlacePageInput.class.getName());
		this.setInput(input);
	}

	@Override
	public void createPartControl(Composite parent) {
		map = new GoogleMaps(parent, SWT.NONE, "http://www.dftproject.org/genesis/googlemap.htm");
		map.runAfterLoading(new Runnable() {
			
			public void run() {
				map.setLargeMapControlVisible(true);
				map.setMapTypeControlVisible(true);
				map.setAddress(((PlacePageInput) getInput()).getPlace().toString());
			}
			
		});
	}

	@Override
	public void dispose() {
	}

	@Override
	public void setFocus() {
		//
	}
	
}
